<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  
  <style type="text/css">
  	p{
  	text-align: center;
  	color: red;
  	}
  </style>
  </head>
  
  <body>
		<h1 style="text-align: center;">我的京东_修改商品</h1> <hr/>
		
		<form action="${pageContext.request.contextPath }/seller/updateProd"
			  method="post" enctype="multipart/form-data">

			<input type="hidden" name="id" value="${prod.id}">

			<table border="1" cellspacing="0" cellpadding="10" align="center">
					<tr>
						<td>商品名称:</td>
						<td> <input type="text" name="name" value="${prod.name}"
									size="40" maxlength="20" required/> </td>
					</tr>
					<tr>
						<td>单价:</td>
						<td> <input type="number" name="price" value="${prod.price}"
									min="0" step="0.01"  required/> </td>
					</tr>
					
					<tr>
						<td>商品种类:</td>
						<td> <select name="typeid" id="s1"  required>
							<option value="">请选择</option>

						</select> 
						</td>
					</tr>
					
					<tr>
						<td>库存数量:</td>
						<td> <input type="number" name="pnum" value="${prod.pnum}" min="0" step="1"  required/> </td>
					</tr>
					
					<tr>
						<td>选择新图片:</td>
						<td>
							<img src="${applicationScope.pic_url }${prod.imgurls}"/>
							<input type="file" name="aa"/> </td>
					</tr>
					
					
					<tr>
						<td>描述信息:</td>
						<td> <textarea name="description" rows="10" cols="30"  required>${prod.description}</textarea> </td>
					</tr>
					<tr>
						<td colspan="2" align="center">  
							<input type="submit" value="修改商品" />
							<input type="reset" value="重置"/>
						</td>
					</tr>
			</table>
		</form>
  </body>

<script src="${pageContext.request.contextPath}/js/jquery-1.12.4.js"></script>

<script>

	$.post("${pageContext.request.contextPath}/types",function(result){
			if(result.code == 200){
				for(var i = 0;i<result.obj.length;i++){
					var  type = result.obj[i];
					if(type.id == '${prod.typeid}'){
						$("#s1").append('<option selected value="'+type.id+'">'+type.name+'</option>');
					}else{
						$("#s1").append('<option value="'+type.id+'">'+type.name+'</option>');
					}

				}
			}
	},"json")

</script>
</html>
